package com.dandelion.common.dao.manual;

import com.dandelion.common.domain.AddressTreeVO;
import com.dandelion.common.domain.CategoryVO;
import com.dandelion.common.domain.CustomServiceVO;
import com.dandelion.common.domain.ExpressComponayVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DictDataDao {
    @Select("select `id`, `name`, `is_leaf` as isLeaf from t_category_tree where is_deleted=0 and parent_id=#{parentId} order by id asc")
    List<CategoryVO> selectCategoryList(@Param("parentId") int parentId);

    @Select("select `parent_id` as parentId, `id`, `name`, `is_leaf` as isLeaf from t_category_tree where is_deleted=0 order by id asc")
    List<CategoryVO> selectAllCategoryList();

    @Select("select `name` from t_category_tree where `id`=#{catId}")
    String selectCatNameById(@Param("catId") int catId);

    @Select("select `name` from t_custom_service where `id`=#{svrId}")
    String selectCustomServiceNameById(@Param("svrId") int svrId);

    @Select("select t1.`id`, t1.`name`,t1.`show_bld_lift` as showBldLift, `description` from t_service_category_relation t0, t_custom_service t1 where t0.is_deleted=0 and t1.is_deleted=0 and  t0.svr_id=t1.id and t0.cat_id=#{topCatId} order by t1.id asc")
    List<CustomServiceVO> selectCustomServiceByTopCategoryId(@Param("topCatId") int topCatId);

    @Select("select `code`, `name` from t_address_tree where is_deleted=0 and parent_code=#{parentCode} order by convert(`name` using gbk) asc")
    List<AddressTreeVO> selectAddressList(@Param("parentCode") String parentCode);

    @Select("select `id`, `name` from t_expr_company where is_deleted=0 order by convert(`name` using gbk) asc")
    List<ExpressComponayVO> selectAllExprCompany();

    @Select("select `name` from t_expr_company where id=#{comId}")
    String getExprComNameById(@Param("comId") Integer comId);
}
